import {} from 'cloud'

export const storage = {
  delFile: function (files, cb) {
    wx.cloud.deleteFile({
      fileList: files
    }).then(res => {
      if (cb) cb();
    }).catch(error => {
      wx.showToast({
        title: '删除失败',
        icon: 'fail',
        duration: 1000,
        mask: true
      })
    })
  },
  uploadFile: function (fileName, tempFile, cb) {
    wx.cloud.uploadFile({
      cloudPath: fileName,
      filePath: tempFile, // 文件路径
    }).then(res => {
      // console.log(res)
      if (cb) cb(res.fileID)
    })
  }
}